@echo off
echo ========================================
echo 测试员工模块API
echo Testing Employee API
echo ========================================
echo.

echo [1/4] 测试员工列表 GET /api/employees
powershell -Command "$response = Invoke-RestMethod -Uri 'http://localhost:8080/api/employees' -Method Get; Write-Host '状态码: 200 OK' -ForegroundColor Green; Write-Host '员工数量:' $response.total; $response.data | Format-Table -AutoSize"
echo.

echo [2/4] 测试查询单个员工 GET /api/employees/1
powershell -Command "try { $response = Invoke-RestMethod -Uri 'http://localhost:8080/api/employees/1' -Method Get; Write-Host '状态码: 200 OK' -ForegroundColor Green; $response.data | Format-List } catch { Write-Host '员工不存在或服务未启动' -ForegroundColor Yellow }"
echo.

echo [3/4] 测试新增员工 POST /api/employees
powershell -Command "$body = @{ empNo='E1003'; name='王五'; dept='测试部'; status=1 } | ConvertTo-Json; try { $response = Invoke-RestMethod -Uri 'http://localhost:8080/api/employees' -Method Post -Body $body -ContentType 'application/json'; Write-Host '创建成功!' -ForegroundColor Green; $response.data | Format-List } catch { Write-Host '创建失败（可能工号已存在）' -ForegroundColor Yellow }"
echo.

echo [4/4] 再次查询员工列表
powershell -Command "$response = Invoke-RestMethod -Uri 'http://localhost:8080/api/employees' -Method Get; Write-Host '当前员工总数:' $response.total -ForegroundColor Cyan; $response.data | Select-Object id, empNo, name, dept, status | Format-Table -AutoSize"

echo.
echo ========================================
echo 测试完成！
echo 现在可以访问: http://localhost:8080/employee.html
echo ========================================
pause

